#ifndef SLIDER_H
#define SLIDER_H

#include <string>
#include "../Widget.h"

namespace PickinOpenSticks {
    namespace Ui {

        class Slider : public Widget {
        public:

            Slider() : curValue(0), lowerLimit(0), upperLimit(100), drag(false), hotSpotX(0), hotSpotY(0) {
                movable = false;
                type = SLIDER;
            }

            Slider(int upper, int lower) {
                SetLimits(upper, lower);
            }

            ~Slider() {
            }
            void SetDefaultImage();
            void SetCursorImage(const std::string& filename);
            void SetBackgroundImage(const std::string& filename);

            inline void SetLimits(int lower, int upper) {
                if (lower < upper) {
                    upperLimit = upper;
                    lowerLimit = lower;
                } else {
                    upperLimit = lower;
                    lowerLimit = upper;
                    cout << "Lower limit is bigger than the upper limit! Switching them.. " << endl;
                }
            }

            inline int GetValue() {
                return curValue;
            }

            inline void SetValue(int value) {
                curValue = value;
            }
        private:
            int curValue;
            int lowerLimit, upperLimit;
            sf::Sprite cursor;
            bool drag; //drag flag
            int hotSpotX, hotSpotY; //used for drag
        protected:
            void Update(int diff);
            void Draw(sf::RenderTarget* target);

            //event handling functions
            virtual void OnClickPressed(sf::Event* event);
            virtual void OnClickReleased(sf::Event* event);
            virtual void OnOtherEvents(sf::Event* event);
            /*
            virtual void OnKeyPressed(sf::Event* event) {cout << GetName() << ": Key Pressed" << endl;}
            virtual void OnKeyReleased(sf::Event* event) {cout << GetName() << ": Key Released" << endl;}
            virtual void OnOtherEvents(sf::Event* event) {cout << GetName() << ": Other Event! " << event->Type << endl;}
            virtual void OnTextEntered(sf::Event* event) {cout << GetName() << ": TextEntered! : " << (int)event->Text.Unicode << endl;}
             */


        };

    }
}

#endif
